package com.hongsheng.mapper;

import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.hongsheng.pojo.Line;

import org.apache.ibatis.annotations.*;

import java.util.List;

/**
 * ClassName:LineMapper
 * Description:
 *
 * @Author: 曾晋冠
 * @Version: 2022.3.2
 * @Create: 2023/8/12 - 13:24
 */
@Mapper
public interface LineMapper extends BaseMapper<Line>{
    /**
     * 查询全部
     * @return
     */
    @Select("select * from tb_line")
    List<Line> findAllLine();

    /**
     * 添加
     * @param line
     * @return
     */
    @Insert("insert into tb_line  values (null,#{startAddress},#{endAddress},#{distance})")
    Boolean insertLine(Line line);

    /**
     * 修改
     * @param line
     * @return
     */
    @Update("update tb_line set start_address=#{startAddress},end_address=#{endAddress},distance=#{distance} where id=#{id}")
    Boolean updateLine(Line line);

    /**
     * 删除
     * @param id
     * @return
     */
    @Delete("delete from tb_line where id=#{id}")
    Boolean deleteLine(Integer id);

    /**
     * id查询
     * @param id
     * @return
     */
    @Select("select * from tb_line where id=#{id}")
    Line findAllById(Integer id);

    IPage<Line> getPageLine(IPage iPage, LambdaQueryWrapper<Line> wrapper);
}
